<%@include file="/page/tag.jsp"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<!--框架必需start-->
<script type="text/javascript" src="${ctp}/QUI/libs/js/jquery.js"></script>
<script type="text/javascript" src="${ctp}/QUI/libs/js/language/cn.js"></script>
<script type="text/javascript" src="${ctp}/QUI/libs/js/framework.js"></script>
<link href="${ctp}/QUI/libs/css/import_basic.css" rel="stylesheet" type="text/css"/>
<link href="${ctp}/QUI/libs/skins/lightBlue/style.css" rel="stylesheet" type="text/css" id="theme" themeColor="lightBlue"/>
<!--框架必需end-->

<!--数据表格start-->
<script src="${ctp}/QUI/libs/js/table/quiGrid.js" type="text/javascript"></script>
<!--数据表格end-->

<!--布局控件start-->
<script type="text/javascript" src="${ctp}/QUI/libs/js/nav/layout.js"></script>
<!--布局控件end-->

<!--箭头分页start-->
<script type="text/javascript" src="${ctp}/QUI/libs/js/nav/pageArrow.js"></script>
<!--箭头分页end-->

<!--树组件start -->
<script type="text/javascript" src="${ctp}/QUI/libs/js/tree/ztree/ztree.js"></script>
<link href="${ctp}/QUI/libs/js/tree/ztree/ztree.css" rel="stylesheet" type="text/css"/>
<!--树组件end -->

<!-- 日期选择框start -->
<script type="text/javascript" src="${ctp}/QUI/libs/js/form/datePicker/WdatePicker.js"></script>
<!-- 日期选择框end -->

<style>
.right_border{
	border-right: 1px solid;
}

.a_button{
    display: inline-block;
    width: 24px;
	height: 20px;
    line-height: 22px;
    background: url("${ctp}/QUI/libs/skins/lightBlue/form/btn_bg.jpg") 0px 0px repeat scroll transparent;
    border: 1px solid rgb(157, 194, 246);
    padding: 1px 6px;
}
.a_button:hover {
    background-image: url(${ctp}/QUI/libs/skins/lightBlue/form/btn_bg_hover.jpg)!important;
    border: 1px solid #af923f!important;
}
a{TEXT-DECORATION:none; color:#000;}
</style>
</head>
<body style="background-color:#ffffff;">

<div id="layout1">
        <div id="leftCon" position="left" style="" panelTitle="组织机构">
        	<div style="text-align: center;">
	        	<a id="deptAddBtn" class="a_button" href="javascript:void(0);" style="">添加</a>
	        	<a id="deptEditBtn" class="a_button" href="javascript:void(0);" style="">编辑</a>
	        	<a id="deptDelBtn" class="a_button" href="javascript:void(0);" style="">删除</a>
        	</div>
        
        	<div class="orgTreeContainer">
        		<ul id="tree-1" class="ztree"></ul>
        	</div>
        </div>
        
        <div id="centerCon" position="center" style="">
        
			<div class="box2" panelTitle="条件查询" id="searchPanel" startState="open">
				<form id="searchF">
					<input type="hidden" name="pageNo" value="1"/>
					<input type="hidden" name="pageSize" value="20"/>
					<input id="h_orderBy" type="hidden" name="orderBy" value="sortIndex"/>
					<input id="h_order" type="hidden" name="order" value="desc"/>
					
					<table class="tableStyle" >
						<tr>
							<td>
								名字:
							</td>
							<td colspan="3">
								<input type="text" style="width: 80%" name="filter_LIKES_userName"/>
							</td>
							
							<td>
								手机号码:
							</td>
							<td>
								<input type="text" style="width: 70%;" name="filter_LIKES_userPhone"/>
							</td>
						</tr>
						
						<tr>
							<td>
								工号:
							</td>
							<td >
								<input type="text" style="width: 70%;"  name="filter_LIKES_userCode"/>
							</td>
							
							<td>
								账号:
							</td>
							<td >
								<input type="text" style="width: 70%;"  name="filter_LIKES_userAccount"/>
							</td>
							
							<td colspan="2" style="text-align: center;">
								<input type="button" value="查询" onclick="searchFF()" />
								<input type="button" value="刷新" onclick="reflushList()" />
							</td>
						</tr>
						
					</table>
				</form>
			</div> 
			
			<div class="padding_right5">
				<div id="maingrid">
			    </div>
			</div>	
			
			<div id="pageContent" style="height:35px;"></div> 	
      </div>
        
    </div> 

<script type="text/javascript" src="${ctp}/js/list.js"></script>
<script type="text/javascript" src="${ctp}/js/httpUtil.js"></script> 
<script type="text/javascript" src="${ctp}/js/dateUtil.js"></script> 
<script type="text/javascript">
var g_pageNo = 1;
var g_pageSize = 20;
//数据表格使用
var g;
var gridData;
function initComplete(){
	getLeftComparyInfo();
	g = $("#maingrid").quiGrid({
		columns: [ 
		          { display: 'id', isAllowHide: false, name: 'sysUserInfoId',hide:true },
		          { display: '名字',  name: 'userName',  isAllowHide: false,   align: 'center',  width:"30%" },
		          { display: '工号',  name: 'userCode',  isAllowHide: false,   align: 'center',  width:"15%" },
		          { display: '手机号码',  name: 'userPhone',  isAllowHide: false,   align: 'center',  width:"15%" },
		          { display: '账号',  name: 'userAccount',  isAllowHide: false,   align: 'center',  width:"10%" },
		          { display: '创建时间', name: 'createTime', isAllowHide: false, align: 'center',  width:"15%", type:"date" },
		          { display: '操作', isAllowHide: false, align: 'center',  width:"10%", render: function (rowdata, rowindex, value, column){
					  return '<div class="padding_top4 padding_left5">'
					  + '<span class="img_view hand" title="查看" onclick="onView(\'' + rowdata.sysUserInfoId+ '\')"></span>' 
					  + '<span class="img_edit hand" title="编辑" onclick="onEdit(\'' + rowdata.sysUserInfoId+ '\')"></span>' 
					  + '<span class="img_delete hand" title="删除" onclick="onDel(\'' + rowdata.sysUserInfoId+ '\')"></span>' 
					  + '</div>';
					}
				  }
		          ], 
		          data:[],
		          sortName: 'sortIndex',
		          sortOrder: 'desc',
		          rownumbers:true,
		          percentWidthMode:true,
		          dataAction:'dataAction',
		          enabledSort:true,
		          checkbox:false,
		          usePager: false,
		          height: '95%',
		          width:"100%",
		          frozen:false,
		          toolbar:{
		        	  items:[
		        	         {text: '新增', click: addColumn,    iconClass: 'icon_add'}
		        	         ]
		          }, 
		          onChangeSort : function(){
		        	  $("#h_orderBy").val(g.options.sortName);
		        	  $("#h_order").val(g.options.sortOrder);
		        	  var data = $("#searchF").serialize();
		        	  getData(g.options.url, data);
		        	  return false;
		          },
		          onDblClickRow:function(rowdata, rowindex, rowDomElement){
		        	  onView(rowdata.sysUserInfoId);
		          }
	});
}

$(function(){
	g.options.url = "${ctp}/sysUserInfo/sysUserInfo_list.do";
	g.options.data = {
			"pageNo": g_pageNo,
			"pageSize": g_pageSize,
			"orderBy": "sortIndex",
			"order": "asc"
	};
	getData(g.options.url, g.options.data);
});

//更新
function onEdit(id){
	top.Dialog.open({
		URL:"${ctp}/sysUserInfo/sysUserInfo_edit.html?id=" + id ,
		Title:"更新人员",
		Width:800,
		Height:450
	});
}

//查看
function onView(id){
	top.Dialog.open({
		URL:"${ctp}/sysUserInfo/sysUserInfo_detail_" + id + ".html",
		Title:"查看",
		Width:800,
		Height:450
	});
}

function onDel(id){
	top.Dialog.confirm("是否确定删除？",
			function(){
				$.ajax({
					url:"${ctp}/sysUserInfo/sysUserInfo_del_" + id + ".do",
					success:function(data){
						if(data.result){
							top.frmright.reflushList();
							top.Dialog.alert(data.msg, null, null, null, 2);
						} else{
							top.Dialog.alert(data.msg, null, null, null, 2);
						}
					}
				});
			},
			function(){top.Dialog.close();});
}

function searchFF(){
	var data = $("#searchF").serialize();
	getData(g.options.url, data);
}

var leftTree, currTreeNode=undefined;
//左侧部门树
function getLeftComparyInfo(){
	$("#layout1").layout({ leftWidth: 150,onEndResize:function(){
	  	g.resetWidth();
	  }});
	
	$.get("${ctp}/sysUserInfo/getUserCompanyTreeJson.do", function(data){
		leftTree = $.fn.zTree.init($("#tree-1"), {callback:{onClick:onClickTree}}, data.list);
		if(currTreeNode != undefined){
			leftTree.selectNode(currTreeNode);
		}
      });
}

function onClickTree(event, treeId, treeNode, clickFlag){
	currTreeNode = treeNode;
	if(currTreeNode.flag == 1){
		var data = {
				"pageNo": 1,
				"pageSize": g_pageSize,
				"orderBy": "sortIndex",
				"order": "asc",
				"filter_EQS_sysDept.sysDeptId":currTreeNode.id
		};
		getData(g.options.url, data);
	}
}
</script> 


<c:choose>
	<c:when test="${sessionScope.userInfo.userType.equals(UserType.MASTER_key)  }">
		<script type="text/javascript">
			$(function(){
	        	$("#deptAddBtn").click(function(){
	        		if(currTreeNode == undefined){
	        			top.Dialog.alert("请选择公司|消息");
	        			return false;
	        		}
	        		
	        		var url = "";
	        		if(currTreeNode.flag == 0){
	        			url = "${ctp}/sysDept/sysDept_edit.html?sysCompanyInfoId=" + currTreeNode.id;
	        		} else{
	        			url = "${ctp}/sysDept/sysDept_edit.html?sysCompanyInfoId=" + currTreeNode.companyId + "&sysDeptId="+currTreeNode.id;
	        		}
	        		top.Dialog.open({
	        			URL:url,
	        			Title:"新增部门",
	        			Width:800,
	        			Height:450
	        		});
	        	});
	        	
	        	$("#deptEditBtn").click(function(){
	        		if(currTreeNode == undefined || currTreeNode.flag==0){
	        			top.Dialog.alert("请选择部门|消息");
	        			return false;
	        		}
	        		
	        		top.Dialog.open({
	        			URL:"${ctp}/sysDept/sysDept_edit.html?id="+currTreeNode.id,
	        			Title:"编辑部门",
	        			Width:800,
	        			Height:450
	        		});
	        	});
	        	
	        	$("#deptDelBtn").click(function(){
	        		if(currTreeNode == undefined || currTreeNode.flag==0){
	        			top.Dialog.alert("请选择部门|消息");
	        			return false;
	        		}
	        		
	        		top.Dialog.confirm("是否确定删除此部门？",
	        				function(){
	        					$.ajax({
	        						url:"${ctp}/sysDept/sysDept_del_" + currTreeNode.id + ".do",
	        						success:function(data){
	        							if(data.result){
	        								top.frmright.getLeftComparyInfo();
	        								top.Dialog.alert(data.msg, null, null, null, 2);
	        							} else{
	        								top.Dialog.alert(data.msg, null, null, null, 2);
	        							}
	        						}
	        					});
	        				},
	        				function(){top.Dialog.close();});
	        	});
	        	
			});			
			
			//新增
			function addColumn(){
				if(currTreeNode == undefined || currTreeNode.flag==0){
					top.Dialog.alert("请选择部门|消息");
					return false;
				}
				
				top.Dialog.open({
					URL:"${ctp}/sysUserInfo/sysUserInfo_edit.html?deptId="+currTreeNode.id + "&deptName="+currTreeNode.name+"&companyId="+currTreeNode.companyId,
					Title:"新增人员",
					Width:800,
					Height:450
				});
			}
		</script>
	</c:when>
	<c:otherwise>
		<script type="text/javascript">
		$(function(){
        	$("#deptAddBtn").click(function(){
        		if(currTreeNode == undefined){
        			top.Dialog.alert("请选择公司|消息");
        			return false;
        		}
        		
        		var url = "";
        		if(currTreeNode.flag == 0){
        			url = "${ctp}/sysDept/sysDept_edit.html";
        		} else{
        			url = "${ctp}/sysDept/sysDept_edit.html?sysDeptId="+currTreeNode.id;
        		}
        		top.Dialog.open({
        			URL:url,
        			Title:"新增部门",
        			Width:800,
        			Height:450
        		});
        	});
        	
        	$("#deptEditBtn").click(function(){
        		if(currTreeNode == undefined || currTreeNode.flag==0){
        			top.Dialog.alert("请选择部门|消息");
        			return false;
        		}
        		
        		top.Dialog.open({
        			URL:"${ctp}/sysDept/sysDept_edit.html?id="+currTreeNode.id,
        			Title:"编辑部门",
        			Width:800,
        			Height:450
        		});
        	});
        	
        	$("#deptDelBtn").click(function(){
        		if(currTreeNode == undefined || currTreeNode.flag==0){
        			top.Dialog.alert("请选择部门|消息");
        			return false;
        		}
        		
        		top.Dialog.confirm("是否确定删除此部门？",
        				function(){
        					$.ajax({
        						url:"${ctp}/sysDept/sysDept_del_" + currTreeNode.id + ".do",
        						success:function(data){
        							if(data.result){
        								top.frmright.getLeftComparyInfo();
        								top.Dialog.alert(data.msg, null, null, null, 2);
        							} else{
        								top.Dialog.alert(data.msg, null, null, null, 2);
        							}
        						}
        					});
        				},
        				function(){top.Dialog.close();});
        	});
        	
		});	
		
		function addColumn(){
			if(currTreeNode == undefined || currTreeNode.flag==0){
				top.Dialog.alert("请选择部门|消息");
				return false;
			}
			
			top.Dialog.open({
				URL:"${ctp}/sysUserInfo/sysUserInfo_edit.html?deptId="+currTreeNode.id + "&deptName="+currTreeNode.name,
				Title:"新增人员",
				Width:800,
				Height:450
			});
		}
		</script>
	</c:otherwise>
</c:choose>

</body>
</html>
